<?php
class AboutAction extends CommonAction{
	
	
	
  	function  index(){     

						import('ORG.Util.Page');

					 $count=M('About')->count();// 查询总数据记录

					 $Page = new Page($count,C('PAGESIZE'));

					 $show= $Page->show();

	                    $list = M('About')->order("id DESC")->limit($Page->firstRow.','.$Page->listRows)->select();

	                    

	                      $this->assign("list",$list);

						  $this->assign("page",$show);

                          $this->display();


       }

       

       

       function add(){

   	  	
   	  	if(isset($_POST['submit'])){
   	  	       $data = $_POST;
           $data['createtime']=mktime();
           $data['status']= 1 ;
   	  	    if(M('About')->add($data)){
   	  	    	$this->success("添加文章成功！",U('index'));
   	  	    }else{
   	  	    	
   	  	    	$this->error("添加文章失败");
   	  	    }
   	  	}else{
   	  		$this->list =M('Category')->select();
   	  		$this->display();
   	  	}
       	
       }


  	

  	   /**

  	    * 

  	    * 编辑文章

  	    */

    	function  edit(){
	              $id= htmlspecialchars($_GET['id']);
	              if(is_numeric($id)){
	              	  if(isset($_POST['submit'])){
	              	  	  $data = $_POST;
	              	  	  $data['createtime']=mktime();
	              	  	  M('About')->where("id=".$id)->save($data);
	              	  	  /*
	              	  	  $this->success("更新成功！",U('index'));
	              	  */
	              	  }else{
	              	  
	              	  	$this->li =M('About')->where("id=".$id)->find();
	              	  	$this->display();
	              	  }
	              	
	              }
    		
  		

  	 }

  	 

	
}
?>